<?php

  include_once CORE_DIR.'/controllers/controller.php';

   
    class messengerController extends Controller {

        public function messengerController(&$target)
        {
            Controller::Controller($target);
            if ($this->target->user->display_name() == '') {
                $this->redirect('/profile/login', 'Please, login first');
            }
        }


        public function mainAction()
        {
        }


        public function testAction()
        {
        }


        public function dialogAction()
        {
            $email    = isset($_REQUEST['email']) ? $_REQUEST['email'] : 'nonexists@email.tst';
            $opponent = new profile($email, $this->target);

            if ($opponent->display_name() == '' || $opponent->get('id') == $this->target->user->get('id')) {
                $this->redirect('/messenger', 'Error!');
            }


            $this->target->assign( 'user',     $this->target->user );
            $this->target->assign( 'opponent', $opponent );
        }



        /**
         * Send an message to opponent
         */
        public function sendAction()
        {
        }



        /**
         * Send an message to opponent
         */
        public function getAction()
        {
        }

    }